<%@ page import="BusinessLogic.ControllerFacade" %>
<%@ page import="Presentation.WebUI.LinksGenerator" %>
<%@ page import="java.util.Collection" %>
<%//@ page errorPage="error.jsp" %>

<%
	ControllerFacade c = (ControllerFacade)session.getAttribute("c");
    String movieNumber = request.getParameter("movieNumber");

    int amount = c.getListLength();
    int start = 0;
    String startParam = request.getParameter("start");
    if (startParam != null)
        start = Integer.parseInt(startParam);
%>

<h2>Users rated more than <%=movieNumber%> movies in the last month</h2>

<%

    Collection<String> list = c.getUsersRatedLastMonth(Integer.parseInt(movieNumber),start);

    if(list.size() != 0){
        out.println("<ul>");
        for(String m : list)
        {
            out.println("<li>"+LinksGenerator.userLink(m)+"</li>");
        }
        out.println("</ul>");

        String nav = LinksGenerator.navLinks(request.getParameterMap(), start, amount);
        out.print(nav);
    }
    else{
        out.println("<br />No More Users<br /><br />");
        String prevLink = LinksGenerator.navLink(request.getParameterMap(), start - amount, "prev");
        out.println(prevLink);
    }
%>
